package helpers;

import java.util.regex.Pattern;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import debugs.DomainDebug;

import entities.Domain;

public class CrawlerHelper {
	private static String url = "http://www.whoismind.com/whois/";
	
	public static String getWhois(String name) {
		String whois = "";
		try {
			Document doc = Jsoup.connect(url + name + ".html").get();
			
			whois = doc.select("#whois-rawinfo .whois_raw > div:eq(1)").html();
			if (!whois.isEmpty()) {
				whois = whois.replaceAll("[<]{1}(a)[^>]+[>]{1}", "").replaceAll("<\\/a>", "");
				whois = whois.replaceAll("(src=\")", "src=\"http://www.whoismind.com");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return whois;
	}
}
